<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>PHP 5.6.x 中已废止的特性</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="migration56.new-features.html">« 新特性</a></li>
      <li style="float: right;"><a href="migration56.changed-functions.html">函数的变化 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="migration56.html">从 PHP 5.5.x 移植到 PHP 5.6.x</a></li>
    <li>PHP 5.6.x 中已废止的特性</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="migration56.deprecated" class="sect1">
 <h2 class="title">PHP 5.6.x 中已废止的特性</h2>

 <div class="sect2" id="migration56.deprecated.incompatible-context">
  <h3 class="title">从不兼容的上下文调用方法</h3>

  <p class="para">
   现在已废止从不兼容的上下文调用方法，
   并且产生 <strong><code>E_DEPRECATED</code></strong> 错误
   （以前是 <strong><code>E_STRICT</code></strong>）。
   在 PHP 的后续版本中可能彻底移除对此特性的支持。
  </p>

  <p class="para">
   以下是不兼容上下文调用方法的示例：
  </p>

  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">A&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">f</span><span style="color: #007700">()&nbsp;{&nbsp;echo&nbsp;</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">);&nbsp;}<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">B&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">f</span><span style="color: #007700">()&nbsp;{&nbsp;</span><span style="color: #0000BB">A</span><span style="color: #007700">::</span><span style="color: #0000BB">f</span><span style="color: #007700">();&nbsp;}<br />}<br /><br />(new&nbsp;</span><span style="color: #0000BB">B</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">f</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <p class="para">以上例程会输出：</p>
   <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Non-static method A::f() should not be called statically, assuming $this from incompatible context in - on line 7
B
</pre></div>
   </div>
  </div>
 </div>

 <div class="sect2" id="migration56.deprecated.raw-post-data">
  <h3 class="title"><var class="varname">$HTTP_RAW_POST_DATA</var> 和 <code class="literal">always_populate_raw_post_data</code></h3>

  <p class="para">
   使用 <code class="literal">always_populate_raw_post_data</code>
   会导致在填充 <var class="varname">$HTTP_RAW_POST_DATA</var> 时产生 <strong><code>E_DEPRECATED</code></strong> 错误。
   请使用 <a href="wrappers.php.html#wrappers.php.input" class="link"><code class="literal">php://input</code></a> 替代
   <var class="varname">$HTTP_RAW_POST_DATA</var>，
   因为它可能在后续的 PHP 版本中被移除。
   设置 <code class="literal">always_populate_raw_post_data</code>
   为 <code class="literal">-1</code> 
   （这样会强制 <var class="varname">$HTTP_RAW_POST_DATA</var> 未定义，所以也不回导致 <strong><code>E_DEPRECATED</code></strong> 的错误）
   来体验新的行为。
  </p>
 </div>

 <div class="sect2" id="migration56.deprecated.iconv-mbstring-encoding">
  <h3 class="title"><a href="book.iconv.html" class="link">iconv</a> 和 <a href="book.mbstring.html" class="link">mbstring</a> 编码设置</h3>

  <p class="para">
   <a href="book.iconv.html" class="link">iconv</a> 和
   <a href="book.mbstring.html" class="link">mbstring</a> 配置选项中
   和编码相关的选项都已废弃，
   请使用 <a href="ini.core.html#ini.default-charset" class="link"><code class="parameter">default_charset</code></a>。
   废弃的选项有：
  </p>

  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     <a href="iconv.configuration.html#ini.iconv.input-encoding" class="link"><code class="parameter">iconv.input_encoding</code></a>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <a href="iconv.configuration.html#ini.iconv.output-encoding" class="link"><code class="parameter">iconv.output_encoding</code></a>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <a href="iconv.configuration.html#ini.iconv.internal-encoding" class="link"><code class="parameter">iconv.internal_encoding</code></a>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <a href="mbstring.configuration.html#ini.mbstring.http-input" class="link"><code class="parameter">mbstring.http_input</code></a>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <a href="mbstring.configuration.html#ini.mbstring.http-output" class="link"><code class="parameter">mbstring.http_output</code></a>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <a href="mbstring.configuration.html#ini.mbstring.internal-encoding" class="link"><code class="parameter">mbstring.internal_encoding</code></a>
    </span>
   </li>
  </ul>
 </div>
</div></div></div></body></html>